<template>
	<view class="home">
		<u-navbar @leftClick="leftClick" @rightClick="rightClick" placeholder :safeAreaInsetTop="true" title="断面信息列表" :fixed="true" rightIcon="plus">
		</u-navbar>
<!-- 		<u-sticky offset-top="0">
			<view class="" style="margin: 20rpx auto;width: 600rpx;">
				<u-button @click="inCezhan" type="warning" shape="circle" text="添加测站"></u-button>
			</view>
		</u-sticky> -->
		<!-- 切换 -->
		<uni-swipe-action>
			<uni-swipe-action-item :right-options="options1" @click="cezhanitem($event,item)"
				v-for="(item, index) in cezhanlist" :key="index">
				<view class="topitem" @click="urlCezhan(item)">
					<view class="topname">
						{{item.name}}
					</view>
					<view class="topdik">
						<view class="">
							测段底宽：
						</view>
						<view class="nubbb">
							{{item.qudikuandu}}
						</view>
					</view>
					<view class="topdik">
						<view class="">
							渠道断面：
						</view>
						<view class="nubbb" v-if="item.xingzhuang == 1">
							矩形
						</view>
						<view class="nubbb" v-if="item.xingzhuang == 0">
							梯形
						</view>
					</view>
					<view class="topdik">
						<view class="">
							测线条数：
						</view>
						<view class="nubbb">
							{{item.cexiantiaoshu}}
						</view>
					</view>
					<view class="topdik">
						<view class="">
							默认测法：
						</view>
						<view class="nubbb">
							{{item.morencefa}}点法
						</view>
					</view>
				</view>
			</uni-swipe-action-item>
		</uni-swipe-action>
		<!-- 切换 -->
	</view>
</template>

<script>
	import {
		cezhan
	} from '@/common/cezhanlist.js';
	// import cezlist '@/common/cezhanlist.js'
	export default {
		data() {
			return {
				cezhanlist: [],
				options1: [{
					text: '删除',
					style: {
						backgroundColor: '#ff0000'
					}
				}]
			}
		},
		onShow() {
			this.cezhanlist = this.vuex_saveCezhandata
			console.log('js', this.cezhanlist);
		},
		onLoad(option) {

		},
		methods: {
			// 返回
			leftClick(){
				uni.navigateBack({
					delta: 1
				});
			},
			// 添加
			rightClick(){
				this.inCezhan()
			},
			urlCezhan(item){
				console.log('item',item);
				uni.navigateTo({
					url: '/pages/cezhanguanli/cezhanXiangqing?&id=' + item.id
				});
			},
			cezhanitem(ev, i) {
				console.log('index', ev, i);
				let it = i.id
				let arr = this.vuex_saveCezhandata
				let index = arr.findIndex(item => item.id == it);  
				if (index !== -1) {  
				  arr.splice(index, 1);  
				}
				console.log('arr',arr)
				this.cezhanlist = arr
				uni.$u.vuex('vuex_saveCezhandata', arr)
				// this.cezhanlist = arr
			},
			inCezhan() {
				let ran01 = new Date().getTime()
				uni.navigateTo({
					url: '/pages/cezhanguanli/increaseShow?&id=' + ran01
				});
			}
		}
	}
</script>
<style scoped lang="scss">
	.topitem {
		width: 650rpx;
		margin: 0rpx auto;
		margin-bottom: 30rpx;
		border-radius: 30rpx;
		border: #ffffff solid 2rpx;
		box-shadow: 2rpx 2rpx 10rpx 2rpx #b8cae1;
		background-color: #ffffff;

		.topname {
			font-size: 50rpx;
			// padding: 15rpx;
			color: #ffffff;
			text-align: center;
			border-radius: 25rpx;
			// margin-bottom: 20rpx;
			// border-bottom: #c6d5da solid 2rpx;
			background-color: #304ea3;
		}

		.topdik {
			font-size: 40rpx;
			padding:  0 20rpx;
			line-height: 70rpx;
			color: #575f62;
			display: flex;
			align-items: center;
			.nubbb {
				color: #304ea3;
			}
		}
	}

	.u-page {
		padding: 0;
	}

	.u-demo-block__title {
		padding: 10px 0 2px 15px;
	}

	.swipe-action {
		&__content {
			padding: 25rpx 0;

			&__text {
				font-size: 15px;
				color: $u-main-color;
				padding-left: 30rpx;
			}
		}
	}
</style>
<style>
	page {
		/* background-color: #f8f8f8; */
	}
</style>